/* SPDX-License-Identifier: GPL-2.0 */
/*
 * HAOC feature support
 *
 * Copyright (C) 2025 ZGCLAB
 * Authors: Lyu Jinglin <lvjl2022@zgclab.edu.cn>
 *          Zhang Shiyang <zhangsy2023@zgclab.edu.cn>
 */

#ifndef _LINUX_HAOC_DEF_H
#define _LINUX_HAOC_DEF_H

/* Place the enum entries in the order corresponding to iee_funcs array. */
enum {
	IEE_OP_MEMCPY,
	IEE_OP_MEMSET,
	IEE_OP_SET_FREEPTR,
#ifdef CONFIG_IEE_PTRP
	IEE_OP_SET_TOKEN_PGD,
	IEE_OP_INIT_TOKEN,
	IEE_OP_INVALIDATE_TOKEN,
	IEE_OP_VALIDATE_TOKEN,
#endif
#ifdef CONFIG_CREDP
	IEE_OP_COPY_CRED,
	IEE_OP_COPY_KERNEL_CRED,
	IEE_OP_INIT_COPIED_CRED,
	IEE_OP_COMMIT_CRED,
	IEE_OP_ABORT_CRED,
	IEE_OP_SET_CRED_UID,
	IEE_OP_SET_CRED_GID,
	IEE_OP_SET_CRED_SUID,
	IEE_OP_SET_CRED_SGID,
	IEE_OP_SET_CRED_EUID,
	IEE_OP_SET_CRED_EGID,
	IEE_OP_SET_CRED_FSUID,
	IEE_OP_SET_CRED_FSGID,
	IEE_OP_SET_CRED_USER,
	IEE_OP_SET_CRED_USER_NS,
	IEE_OP_SET_CRED_GROUP_INFO,
	IEE_OP_SET_CRED_SECUREBITS,
	IEE_OP_SET_CRED_CAP_INHER,
	IEE_OP_SET_CRED_CAP_PERM,
	IEE_OP_SET_CRED_CAP_EFFECT,
	IEE_OP_SET_CRED_CAP_BSET,
	IEE_OP_SET_CRED_CAP_AMBIENT,
	IEE_OP_SET_CRED_JIT_KEYRING,
	IEE_OP_SET_CRED_SESS_KEYRING,
	IEE_OP_SET_CRED_PROC_KEYRING,
	IEE_OP_SET_CRED_THREAD_KEYRING,
	IEE_OP_SET_CRED_REQ_KEYRING,
	IEE_OP_SET_CRED_NON_RCU,
	IEE_OP_SET_CRED_ATSET_USAGE,
	IEE_OP_SET_CRED_ATOP_USAGE,
	IEE_OP_SET_CRED_SECURITY,
	IEE_OP_SET_CRED_RCU,
	IEE_OP_SET_CRED_UCOUNTS,
#endif
	IEE_FLAG_END
};

#ifdef CONFIG_CREDP
#define AT_ADD 1
#define AT_INC_NOT_ZERO 2
#define AT_SUB_AND_TEST 3
#endif

/* The entry gate of all IEE APIs. The first parameter must be a valid
 * IEE function index.
 */
extern unsigned long long iee_rw_gate(int flag, ...);

#define __iee_code		__section(".iee.text")
#define __iee_data		__section(".iee.data")

#endif
